package com.lkxicy.wos.controller;


import com.lkxicy.wos.mapper.ScheduleMapper;
import com.lkxicy.wos.pojo.entity.Schedule;
import com.lkxicy.wos.service.ScheduleService;
import com.lkxicy.wos.utils.Response;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lkxicy
 * @since 2020-11-30
 */
@RestController
@RequestMapping("/wos/v1/schedule")
public class ScheduleController {

    @Autowired
    private ScheduleService scheduleService;

    /**
     * 查看某员工 未来及今天 的排班(未过期)
     * @return
     */
    @GetMapping("searchOneAllNowSchedule")
    public Response searchOneAllNowSchedule(@RequestParam("staffNumber") String staffNumber){
        return Response.success(scheduleService.findOneAllNowSchedule(staffNumber));
    }

    /**
     * 查看某员工 过往(不包含今天) 的排班(未过期)
     * @return
     */
    @GetMapping("searchOneAllPastSchedule")
    public Response searchOneAllPastSchedule(@RequestParam("staffNumber") String staffNumber){
        return Response.success(scheduleService.findOneAllNowSchedule(staffNumber));
    }


    /**
     * 查看某日全公司的排班
     * @return
     */
    @PostMapping("searchSomedaySchedule")
    public Response searchSomedaySchedule(@RequestParam("searchTime") Date searchTime){
        return Response.success(scheduleService.searchSomedaySchedule(searchTime));
    }

    /**
     * 增加排班(安排工作)
     * @return
     */
    @PostMapping("addSchedule")
    public Response addSchedule(@RequestParam("beginTime") Date beginTime,
                                @RequestParam("endTime") Date endTime,
                                @RequestParam("staffNumbers") List<String> staffNumbers,
                                @RequestParam("workContents") List<String> workContents){

        return Response.success(scheduleService.addSchedule(beginTime, endTime, staffNumbers, workContents));
    }

    @PostMapping("deleteSchedule")
    public Response deleteSchedule(@RequestParam("staffNumber") String staffNumber,
                                   @RequestParam("workTime") Date workTime){
        return Response.success(scheduleService.deleteSchedule(staffNumber, workTime));
    }

}

